import Vue from 'vue'
import App from './App'
import router from './router'
import global from '@/components/global'
Vue.prototype.$global = global

import echarts from 'echarts'
Vue.prototype.$echarts = echarts

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
// import { Message } from 'element-ui';
// Vue.prototype.$Message = Message

// 导入全局样式表
import './assets/css/global.css'

import VueCropper from 'vue-cropper' 
Vue.use(VueCropper)

import  VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)


import axios from 'axios'
// 配置请求的跟路径
// axios.defaults.baseURL = 'http://localhost:8081/'
// axios.defaults.baseURL = 'http://lindom.free.idcfengye.com/'
// axios.defaults.baseURL = 'http://3tv5552600.wicp.vip/'
axios.defaults.baseURL = 'http://121.40.128.199:8081/'

// 添加请求拦截器，在请求头中加token
axios.interceptors.request.use(
  config => {
    if (window.localStorage.getItem('token')) {
      config.headers.openID = window.localStorage.getItem('token');
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  });

//响应拦截器  对于响应过滤
axios.interceptors.response.use(
  response => {
    if (response.data.code === 401) {
      window.location.href = '/login'
      this.$message.error("登录过期！");
    }
    return response;
  }
)

Vue.prototype.$http = axios

Vue.config.productionTip = false

// Vue.prototype.$echarts = echarts

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

